<template>
	<view class="container">
		<!-- <uni-nav-bar fixed statusBar left-icon="left" backgroundColor="#ff9000" :border="false" color="#FFFFFF;">
		</uni-nav-bar> -->
		<view class="title">
			<button @tap.stop="jump('/pages/shop/shop')">新增店铺</button>
		</view>
		<scroll-view class="box-list">
			<view class="card-box" v-for="(shop,index) in shopList" :key="index">
				<view class="card-box-head u-flex u-col-center">
					<text class="shop-name">{{shop.name}}</text>
					<text class="order-status">{{shop.status_text}}</text>
				</view>
				<view class="card-box-body card-box-body-cloumn">
					<view class="left-img">
						<image mode="aspectFill" :src="$IMG_URL+shop.logo"></image>
					</view>
					<view class="t-flex-col right-info">
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <image mode="aspectFill" :src="$IMG_URL + (shop.shop_type == 1 ? '/imgs/freelunch/mt-icon.png' : '/imgs/freelunch/elm-icon.png')">
								</image> -->
								店铺类型：
							</view>
							<!-- <view class="right-info-box-num">
							名额<text>1</text>/3
						</view> -->
							<view class="right-info-dec">{{shop.shop_type == 1 ? '美团' : (shop.shop_type == 2 ? '饿了么' : (shop.shop_type == 3 ? '京东' : '未知'))}}</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <uni-icons style="margin-right: 10rpx;" type="calendar" size="22">
								</uni-icons> -->
								手机号码：
							</view>
							<view class="right-info-box-dec">{{shop.mobile}}</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <uni-icons style="margin-right: 10rpx;" type="notification" size="22">
								</uni-icons> -->
								店铺位置：
							</view>
							<view class="right-info-box-dec">{{shop.address}}</view>
						</view>
					</view>
				</view>
				<view v-if="1==2" class="t-flex card-box-footer u-flex u-col-center">
					<view class="t-flex footer-status">
						<!-- <view class="footer-status-view">
							订单号：<text style="color: #666;" class="footer-status-text">12345678987654465445</text>
						</view> -->

					</view>
					<view class="t-flex footer-btn" @tap.stop="jump('/pages/shop/shop-detail?id='+shop.id)">
						<button class="footer-btn-edit">查看详情</button>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="sub" v-if="shopList && shopList.length > 0">
			<button :loading="requestIng" :disabled="requestIng" @tap.stop="goAdmin">进入管理</button>
			<!-- <button v-else style="background: #eee;">提交成功</button> -->
		</view>
		<t-empty v-if="shopList && shopList.length == 0" tipText="空空如也~"></t-empty>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				requestIng: false,
				id: 0,
				// shopList: []
			};
		},
		computed: {
			...mapGetters(['shopList'])
		},
		onLoad(e) {
			if (e?.id > 0) this.id = e.id;
			// this.getShopList();
			this.$store.dispatch('getShopList', e?.id);
		},
		methods: {
			jump(url, type = "navigateTo") {
				this.$util.jump(url, type)
			},
			getShopList() {
				let that = this;
				that.$http('user.shopList', {
						id: that.id
					}).then(res => {
						console.log('shopList', res)
						if (res.code === 1) {
							let shopList = res.data;
							that.shopList = shopList;
							if (shopList && shopList?.length > 0) {
								/* commit('shopList', shopList)
								let temp = [{
									id: 0,
									name: '所有店铺',
									name_text: '所有店铺',
								}];
								let navBarShopList = temp.concat(shopList)
								commit('navBarShopList', navBarShopList)
								// commit('currentShopIndex', 0) */
							}
						} else {
							/* commit('shopList', [])
							commit('navBarShopList', []) */
							// commit('currentShopIndex', -1)
						}
						// resolve(res.data)
					})
					.catch(err => {

					})
			},
			goAdmin() {
				/* let that = this;
				that.$store.commit('selectId', that.id);
				that.$util.loading('进入中');
				setTimeout(() => {
					uni.hideLoading();
					that.$util.jump('/pages/index/index', 'reLaunch');
				}, 1000) */
				this.$store.dispatch('goAdmin', this.id);
			}
		},
	}
</script>

<style lang="scss">
	.t-flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.t-flex-col {
		@extend .t-flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
	}

	.container {
		.box-list {
			margin: 100rpx 0 0;
			padding-bottom: calc(constant(safe-area-inset-bottom) + 150rpx);
			padding-bottom: calc(env(safe-area-inset-bottom) + 150rpx);
		}

		.card-box {
			width: 94%;
			min-height: 100rpx;
			margin: 30rpx 3%;
			padding: 30rpx 0;
			background: #FFF;
			background-size: 100% 100%;
			box-shadow: 0px 7rpx 11rpx 2rpx rgba(213, 175, 97, 0.34);
			border-radius: 30rpx;
			overflow: hidden;
			position: relative;
			// z-index: 810;


			&-head,
			.card-box-footer {
				color: #000;
				font-size: 30rpx;
				display: flex;
				justify-content: space-between;
				width: 94%;
				margin-left: 3%;
				height: 50rpx;
				align-items: center;
			}

			.shop-name,
			.order-status {
				font-size: 30rpx;
				font-weight: 700;
			}

			.order-status {
				color: #ff9000;
			}

			&-body {
				width: 94%;
				margin: 30rpx 3%;
				display: flex;
				align-items: center;

				.left-img {
					width: 140rpx;
					height: 140rpx;
					border-radius: 20rpx;
					margin-right: 20rpx;
				}

				.right-info {
					font-size: 26rpx;
					color: #999;

					&-box {
						justify-content: flex-start;

						&-icon {
							@extend .t-flex;
							justify-content: center;
							height: 60rpx;
							min-width: 130rpx;
							margin-right: 10rpx;

							image {
								width: 38rpx;
								height: 38rpx;
							}
						}

						.right-info-box-num {
							font-size: 28rpx;
							color: #333;
							font-weight: 600;
							margin-right: 10rpx;

							text {
								color: #FF9000;
							}
						}

						.right-info-dec {
							color: #666;
						}
					}
				}
			}

			.card-box-footer {
				font-size: 28rpx;
				color: #666;

				.footer-status {
					.footer-status-view {
						@extend .t-flex;
						justify-content: flex-start;
						margin-right: 10rpx;

						.footer-status-text {
							color: #ff9000;
						}
					}
				}

				.footer-btn {
					button {
						height: 60rp;
						min-width: 140rpx;
						margin: 0 5rpx;
						border: none;
						background: #ff9000;
						border-radius: 80rpx;
						color: #fff;
						font-size: 26rpx;
					}

					.footer-btn-edit {
						background: #fff;
						border: 1px solid #ff9000;
						color: #ff9000;
					}
				}
			}
		}


	}

	image {
		width: 140rpx;
		height: 140rpx;
		border-radius: 10px;
	}

	.title {
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		background: #ff9000;
		width: 100vw;
		border-radius: 0 0 20px 20px;
		position: fixed;
		z-index: 800;
		left: 0;
		right: 0;
		top: 0;

		button {
			width: 160rpx;
			height: 70rpx;
			// border: 1px solid #fff;
			font-size: 24rpx;
			font-weight: 600;
			margin-right: 20rpx;
			border-radius: 70rpx;
			box-shadow: 0px 7rpx 11rpx 2rpx rgba(100, 100, 100, 0.7);
		}
	}

	.sub {
		position: fixed;
		z-index: 2;
		background: #fff;
		height: 80rpx;
		/* #ifdef H5 */
		left: var(--window-left);
		right: var(--window-right);
		bottom: var(--window-bottom);
		/* #endif */
		/* #ifndef H5 */
		left: 0;
		right: 0;
		bottom: 0;
		/* #endif */
		/* padding: 10rpx 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom); */
		padding: 20rpx 0;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);

		button {
			height: 100%;
			margin: 0 10%;
			border: none;
			background: #ff9000;
			border-radius: 80rpx;
			color: #fff;
		}
	}
</style>
